<?php
 // the link that may open the dialog
echo CHtml::link(Yii::t('main','New Service'), array('service/create','user_id'=>$model->user_id), array(
	//'onclick'=>'$("#service-dialog").dialog("open"); return false;',
));

//$this->widget('Dialog', array(
//	'id'=>'service-dialog',
//	'div'=>'serviceForm',
//	'url'=>$this->createUrl('service/create',array('user_id'=>$model->user_id)),
//	'options'=>array(
//		'title'=>'Create Service',
//		'autoOpen'=>false,
//		'modal'=>true,
//		'width'=>750,
//	),
//));
?>

<?php $this->widget('MyGridView', array(
	'id'=>'service-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name'=>'type',
			'value'=>'Lookup::item("ServiceType",$data->type)',
			'filter'=>Lookup::items('ServiceType'),
		),
		'ip',
		array(
			'name'=>'cost',
			'htmlOptions'=>array('class'=>'sum','id'=>'cost'),
			'footer'=>$model->getTotals()->cost, 			//'footer'=>$provider->itemCount===0 ? '' : $model->getTotals(),
			'footerHtmlOptions'=>array('class'=>'total2','id'=>'cost'),
		),
		array(
			'name'=>'cost_this_month',
			'htmlOptions'=>array('class'=>'sum','id'=>'cost_this_month'),
			'footer'=>$model->getTotals()->cost_this_month, 			//'footer'=>$provider->itemCount===0 ? '' : $model->getTotals(),
			'footerHtmlOptions'=>array('class'=>'total2','id'=>'cost_this_month'),
		),
		array(
			'name'=>'packet_id',
			'value'=>'$data->packet->name',
			//'filter'=>$serviceModel->packet->findAll,
		),
		array(
			'name'=>'speed_id',
			'value'=>'$data->speed->name',
		),
		'comment',
		'start_date',
		'end_date',
		array(
			'name'=>'is_blocked',
			'filter'=>Lookup::items('Boolean'),
		),
		array(
			'name'=>'is_active',
			'filter'=>Lookup::items('Boolean'),
		),
		//'pay_date',
		//'last_pay_date',
		array(
			'class'=>'CButtonColumn',
//			'updateButtonOptions'=>array(
//				'title'=>'',
//				'ajax'=>array(
//					'update'=>'dataform',
//					'url'=>Yii::app()->createUrl("update",array("id"=>'$data->id')), // here $data->id is null
//					'dataType'=>'html',
//					'type'=>'POST',
//				),
//			),
			//'template'=>'{view} {update}',
			'viewButtonUrl'=>'Yii::app()->createUrl("admin/service/view",array("id"=>$data->primaryKey))', 		//FIXME link
			'updateButtonUrl'=>'Yii::app()->createUrl("admin/service/update",array("id"=>$data->primaryKey))',
			'deleteButtonUrl'=>'Yii::app()->createUrl("admin/service/delete",array("id"=>$data->primaryKey))',
		),
	),
)); ?>